#include "StdAfx.h"
#include "ChannelGroup.h"

#include <algorithm>
CChannelGroup::CChannelGroup(CHANNEL_GROUP_INFO* pGroupInfo)
				:IBaseClass(IBaseClass::CLASS_CHANNELGROUP)
				, m_strGroupName(pGroupInfo->cGroupName)
				, m_dwID(pGroupInfo->dwID)
{
}

CChannelGroup::~CChannelGroup(void)
{
}

void CChannelGroup::GetGroupInfo(CHANNEL_GROUP_INFO& GroupInfo)
{
	GroupInfo.dwID = m_dwID;
	_tcscpy(GroupInfo.cGroupName, m_strGroupName);
}

BOOL CChannelGroup::FindChannel(CChannel* pChannel)
{
	return find(m_ChannelList.begin(), m_ChannelList.end(), pChannel) != m_ChannelList.end();
}

BOOL CChannelGroup::AddChannel(CChannel* pChannel)
{
	if(NULL == pChannel)
	{
		return FALSE;
	}

	if(find(m_ChannelList.begin(), m_ChannelList.end(), pChannel) == m_ChannelList.end())
	{
		m_ChannelList.push_back(pChannel);
	}

	return TRUE;
}

void CChannelGroup::AddChannelToDomainGroup(CChannel* pChannel)
{
	m_ChannelList.push_back(pChannel);
}

BOOL CChannelGroup::RemoveChannel(CChannel* pChannel)
{
	if(NULL == pChannel)
	{
		return FALSE;
	}

	m_ChannelList.remove(pChannel);
	return TRUE;
}
